package com.cws4cloud.cws.common.core.util;

import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;

/**
 * @ClassName: EncryptConfigUtil
 * @Description: jasypt配置文件加密
 * @Author zhlj
 * @Company:digitalchina
 * @Date 2021/1/26 09:44
 */
public class EncryptConfigUtil {
	public static void main(String[] args) {
		String password = "pig";
		String data = "cms";
		PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
		SimpleStringPBEConfig config = new SimpleStringPBEConfig();
		config.setPassword(password);
		config.setAlgorithm("PBEWithMD5AndDES");
		config.setKeyObtentionIterations("1000");
		config.setPoolSize("1");
		config.setProviderName(null);
		config.setProviderClassName(null);
		config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
//		config.setIvGeneratorClassName("org.jasypt.salt.NoOpIVGenerator");
		config.setStringOutputType("base64");
		encryptor.setConfig(config);
		System.out.println(encryptor.encrypt(data));
	}
}
